package com.yjymm.demo.config;

import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

/**
 * @author yjymm
 * @date 2020-03-24 10:27
 */

@Configuration
public class RootConfig {

    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx){
    return args -> {
        System.out.println("spring boot 注册的所有bean");
        String[] beanDefinitionNames = ctx.getBeanDefinitionNames();
        Arrays.sort(beanDefinitionNames);
        for (String name : beanDefinitionNames) {
            System.out.println(name);
        }
    };
}
}
